#ifndef MEMORYMANAGER_H_INCLUDED
#define MEMORYMANAGER_H_INCLUDED

#include "Atomic.h"

namespace CEngine
{

namespace MemoryManager {
    ///Initializes the memory manager.
    void
    initialize(void);

    ///Returns a pointer to the amount of memory specified.
    ///Allocations are only valid for tempFrames.
    void*
    tempAlloc(U32 bytes);

    ///Returns a pointer to the amount of memory specified.
    ///Allocations must be be freed when you're done with them.
    void*
    rawAlloc(U64 bytes);

    ///Returns a pointer to the constructed object.
    ///Allocations must be be freed when you're done with them.
    template<class object>
    object* alloc(object constructor);

    ///Frees the memory pointed to by pointer.
    ///Must be a pointer given by alloc.
    template<class object>
    void free(object* pointer);

    ///Returns a pointer to a block of memory of newSize.
    ///Copies the old data to the new block, and frees the old pointer.
    void*
    grow(void* pointer, U64 currentSize, U64 newSize);

    ///resets the temperary stack.
    void
    incrementTempStack(void);

    ///prints out information about memory use.
    void
    printMemoryUsage(void);

    ///Returns the number of free bytes in the current temp stack.
    U64
    getTempFreeBytes(void);

    ///Returns the number of free bytes in the heap.
    U64
    getHeapFreeBytes(void);

    ///Returns the number of free bytes in the stack.
    U64
    getStackFreeBytes(void);

    ///Returns the number of free elements in the 24 byte pool.
    U64
    get24PoolFreeElements(void);

    ///Returns the size of the heap's page size.
    U64
    getHeapPageSize(void);

    ///shuts down the memory manager.
    void
    shutdown(void);
}

}

#include "MemoryManagerCore.h"

#endif // MEMORYMANAGER_H_INCLUDED
